/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2204 - C6
 * <p>Powered by webrx On 2022-09-07 14:08:18
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class C6 {
    public static void print(int[] n) {
        for (int i : n) {
            System.out.printf("%d ", i);
        }
        System.out.println();
    }

    public static void print(Integer[] n) {
        //resolve
        for (int i : n) {
            System.out.printf("%d ", i);
        }
        System.out.println();
    }

    /*编写一个方法，求几个数的和*/
    public static int sum(int[] ts, int a, int b) {
        return a + b;
    }

    public static void show(String[] ss) {

    }

    public static int sum(int a, int b, int... t) {
        int s = 0;
        s += a;
        s += b;
        for (int i : t) {
            s += i;
        }
        return s;
    }

    public static void println(Object... o) {
        for (Object ob : o) {
            System.out.println(ob);
        }
    }

    public static int max(boolean isMax,int... n) {
        //int max = n.length >= 1 ? n[0] : 0;
        //for (int i = 1; i < n.length; i++) max = Math.max(max, n[i]);
        //return max;

        Arrays.sort(n);
        return n.length == 0 ? 0 : isMax ? n[n.length-1] : n[0];

    }


    public static void main(String[] args) {
        System.out.println(max(true));
        System.out.println(max(true,10));
        System.out.println(max(false,10));
        System.out.println(max(false,10,3,20,1,200));
        System.out.println(max(true,1000,3,20,1,200));


        //System.out.println(max());
        //System.out.println(max(100));
        //System.out.println(max(100, 90));
       //System.out.println(max(90, 100));
        //System.out.println(max(1, 3000, 10000, 3, 100, 90, 200));
        System.out.println("--------------------------");
        show(null);

        /* 编写3个sum(int...n) max(int...n) min(int...n) */

        println(100, "hello world", 3.5, String.format("%tF", System.currentTimeMillis()), 2 * 3);

        System.out.println(sum(1, 2, 3, 4, 6));
        //System.out.println(sum(6, 9, 12, 99, 5, 3, 6, 8, 12, 3, 52));
        System.out.println("---------");
        //System.out.println(sum(12, 33));
        Integer[] a = {99, 1, 6, 7, 10, 20, 9, 3, 55};
        print(a);
        Arrays.sort(a);
        print(a);
        Arrays.sort(a, (x, y) -> y - x);
        print(a);
    }
}
